package sh.wn36.vehiclemanage.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import sh.wn36.vehiclemanage.entity.CurrentUnit;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import sh.wn36.vehiclemanage.xzy.UnitQuery;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xk
 * @since 2021-04-26
 */
@Service
public interface CurrentUnitMapper extends BaseMapper<CurrentUnit> {

    @Select("select current_unit.*,d.text FROM current_unit LEFT JOIN dictionary d on d.id=current_unit.unit_type ${ew.customSqlSegment}")
    IPage<UnitQuery> selectPage(Page page,@Param(Constants.WRAPPER)Wrapper<UnitQuery> queryWrapper);

    @Select("select DISTINCT d.text,current_unit.unit_type,d.id FROM current_unit LEFT JOIN dictionary d on d.id=current_unit.unit_type")
    List<UnitQuery> selOne();

    @Select("select * from current_unit where unit_type = 33")
    List<CurrentUnit> selectInsu();

    @Select("select * from current_unit where unit_type = 31")
    List<CurrentUnit> selectRefuel();
    @Select("select * from current_unit where unit_type =#{type} ")
    List<CurrentUnit> findTYype(Integer type);

}
